/**
 * 
 */

/**
 * 刷新 admin blogs 列表
 */
function refreshMyBlogsTable(path, page){
	$("#my_blog_list_tbody").empty();
	$("input[type=checkbox]").removeAttr("checked");
	$.ajax({ 
		type:"POST",  
		url:path+"/blog_own.action?page="+page,
		data:{
			title:$("#my_blog_list_search_input").val(), 
		},
		dataType:"json",
		success:function(result){
			if(result.success){  
				var myBlogsList=result.data;
				if(myBlogsList.length==0){ 
					$("#my_blog_list_tbody").empty();  
				}
				for(var i=0;i<myBlogsList.length;i++){ 
					var myBlogInfo=myBlogsList[i];   
					var datetime=new Date(myBlogsList[i].createTime.year,myBlogsList[i].createTime.month,myBlogsList[i].createTime.date,myBlogsList[i].createTime.hours,myBlogsList[i].createTime.minutes,myBlogsList[i].createTime.seconds).format("( MM/dd hh:mm )")
					var $e=$('<tr><td class="" style="text-align:center;"> <input type="checkbox" name="abc" value="'+myBlogInfo.uuid+'" ></td><td class=""><a href="'+path+'/blog_getById.action?id='+myBlogInfo.uuid+'">'+myBlogInfo.title+'</a></td><td class="">'+myBlogInfo.createTime+'</td><td><a class="btn btn-warning" href="'+path+'/blog_updateById.action?id='+myBlogInfo.uuid+'">修改</a></td></tr>'
							); 
					$("#my_blog_list_tbody").append($e); 
				}
				var $p=$('<tr><td colspan="4" style="text-align:center;"><div class="toCenter"> <div id="my_blog_list_pager"></div> </div></td></tr>');
				$("#my_blog_list_tbody").append($p); 
				initMyBlogsPage(path,result.pageBean.curPage,result.pageBean.totalPages); 
				
				 
			}else{
				alertError("操作失败");
			}
		}
	});
}

/**
 * 初始化admin news 列表分页插件 
 * @param curPage
 * @param totalPages 
 */
function initMyBlogsPage(path,curPage,totalPages){ 
	
	if(totalPages==0){
		totalPages=1; 
	}
	
	var options = {
			currentPage : curPage,
			totalPages : totalPages,
			numberOfPages : 5,  
			size:"normal",
			alignment:"right",  
			/*pageUrl : function(type, page, current) {  
				return path + "/blog_blogList.action?rows=10&page=" + page;
			}*/
			onPageClicked: function(e,originalEvent,type,page){
				refreshMyBlogsTable(path,page);
            }
		}
		$('#my_blog_list_pager').bootstrapPaginator(options);
}


/* 获取所有选中项的id字符串   */ 
function getChecked() {  
	var ids="";
	$("input[type=checkbox]").each(function() {
		if ($(this).prop("checked")) {
			ids+=$(this).val()+",";
		} 

	})
	return ids.substr(0,ids.length-1);
}

